package Iterator;

import java.util.Iterator;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * Created by tzs on 2021/7/30.
 */
public class Demo {
    public static Province init(){
        City a = new City("佛山");
        City b = new City("深圳");
        City c = new City("广州");
        SortedMap<Object,City> citys = new TreeMap<>();
        citys.put("a",a);
        citys.put("b",b);
        citys.put("c",c);
        return new Province("广东",citys);
    }

    public static void main(String[] args) {
        Province province = init();
        for (City city :province) {
            System.out.println(city.getName());
        }

       Iterator<City> iterator =  province.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next().getName());
        }

    }


}
